package com.gohi.main.store.hbm.jdbcMapper;



import java.sql.ResultSet;
import java.sql.SQLException;




import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.jdbc.core.RowMapper;

import com.gohi.main.store.hbm.ShopgooGroupbuy;

import com.gohi.main.util.global.GloblConfig;
/**
 * 商铺分类 信息读取
 * @author Administrator
 *
 */
public class GroupbuyMapper implements RowMapper  {

	@Override
	public Object mapRow(ResultSet rs, int arg1) throws SQLException {
		// TODO Auto-generated method stub
		ShopgooGroupbuy s =new ShopgooGroupbuy();

		s.setGroup_id(rs.getInt("group_id"));//主键ID   
		s.setBuyer_count(rs.getInt("buyer_count"));//销售数量
		s.setBuyer_num(rs.getInt("buyer_num"));
		s.setGroup_name(rs.getString("group_name")); 
		s.setGroup_pic(rs.getString("group_pic"));//图片
		s.setStore_name(rs.getString("store_name"));
		s.setGroup_price(rs.getString("group_price"));//团购价格
		s.setAddress(rs.getString("address"));
		s.setGroup_intro(StringEscapeUtils.unescapeHtml(rs.getString("group_intro")));//描述信息
		//String escaped = StringEscapeUtils.escapeHtml4(stringToEscape);
		//.replace("&lt;", "<").replace("&gt;", ">")
		s.setStore_id(rs.getInt("store_id"));

		s.setHowlong(rs.getInt("howlong"));//项目的总耗时
		
		s.setOriginal_price(rs.getString("original_price"));
		//System.err.println(rs.getString("group_intro"));
		//s.setPic(rs.getString("pic"));//轮播图片 逗号隔开
		String sp []= s.getGroup_pic().split(",");
		if(sp.length>1){
			s.setGroup_pic(GloblConfig.IMG_ITEMS+sp[0]);
			for(String pic : sp ){
				if(!pic.trim().equals("")){
				//	System.err.println(pic);
					s.getPiclist().add(GloblConfig.IMG_ITEMS+ pic.replace("_small.jpg", ""));
				}

			}
		}else{
			s.setGroup_pic(GloblConfig.IMG_ITEMS+(sp.length==1?sp[0]:s.getGroup_pic()));
			//添加两次轮播图片
			s.getPiclist().add(GloblConfig.IMG_ITEMS+  (sp.length==1?sp[0]:s.getGroup_pic().replace("_small.jpg", "")));
			s.getPiclist().add(GloblConfig.IMG_ITEMS+  (sp.length==1?sp[0]:s.getGroup_pic().replace("_small.jpg", "")));
		}
		
		//s.setDescription(rs.getString("description"));//描述信息
		return s;
	}




	
}
